{% extends "base.html" %}

{% block title %}图书管理{% endblock %}

{% block content %}
<h2>图书管理</h2>
<button type="button" class="btn btn-success mb-3" onclick="window.location.href='{{ url_for('admin.add_book') }}'">新增图书</button>
<div class="table-responsive">
    <table class="table table-striped">
        <thead>
            <tr>
                <th>ID</th>
                <th>书名</th>
                <th>作者</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {% for book in books %}
            <tr>
                <td>{{ book.id }}</td>
                <td>{{ book.title }}</td>
                <td>{{ book.author }}</td>
                <td>
                    <button type="button" class="btn btn-sm btn-outline-primary" onclick="window.location.href='{{ url_for('admin.edit_book', book_id=book.id) }}'">编辑</button>
                    <form action="{{ url_for('admin.delete_book', book_id=book.id) }}" method="post" style="display:inline;">
                        <button type="submit" class="btn btn-sm btn-outline-danger">删除</button>
                    </form>
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
</div>
{% endblock %}
